package example.my_practice;

import example.entity.User;
import org.apache.commons.lang3.StringUtils;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author guoQ.z
 * @date 2020/11/24 18:06
 * TODO
 */
public class Practice03_Random {

    private static String getHashTable(String subTableFlag, String subTableCount) {

        if (StringUtils.isBlank(subTableFlag)) {
            return null;
        }
        // 删除空格
        String flagTmp = StringUtils.deleteWhitespace(subTableFlag);
        // hash
        int hashCode = flagTmp.hashCode();
        // 分表后缀
        long suffix = hashCode % Long.parseLong(subTableCount);
        // abs
        long abs = Math.abs(suffix);

        return String.valueOf(abs);
    }

    public static void main(String[] args) {
        String str2 = "456";
        User user = new User();

        User user2 = new User();
        user2.setName("haha");

        User user23 = new User();
        user23.setName("456");

        List<User> list = new ArrayList<>();
        list.add(user);
        list.add(user2);
        list.add(user23);
        List<User> collect = list.stream().filter(u -> str2.equals(u.getName())).collect(Collectors.toList());
        System.out.println(collect);
    }

}
